﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Progetto
{
    public class WriteTextFile {

        private FileStream fs;
        private StreamWriter sw;

        private const string path = @"C:\Users\Alessandro Avila\Polito\Primo anno\Programmazione di sistema\C++\";

        private static string fileName;

        public WriteTextFile(string fileName) {
            WriteTextFile.fileName = fileName;
            if (File.Exists(path + fileName))
                fs = new FileStream(path + fileName, FileMode.Truncate);
            else
                fs = new FileStream(path + fileName, FileMode.CreateNew);
            sw = new StreamWriter(fs);
        }

        public void write(string text) {
            sw.WriteLine(text);
            sw.Flush();
        }

        public void newLine() {
            sw.WriteLine();
            sw.Flush();
        }

        public void close() {
            sw.Close();
            fs.Close();
        }

    }
}
